package sys.module.lottery.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import sys.module.lottery.model.PomeModel;
import sys.module.lottery.service.IPomeService;

/**
 * <p>文件名称：PomeController.java</p>
 * <p>文件描述：彩票诗通信接口</p>
 * <p>版权所有： 版权所有(C)2000-2010</p>
 * <p>公    司： CWCA</p>
 * <p>内容摘要：TODO </p>
 * <p>其他说明： </p>
 * <p>完成日期：2014年2月15日</p>
 *
 * @author gao x 
 * @version 1.0 $Id: ican_code_comment.xml,v 1.3 2013/07/03 01:47:35 gaoxiang Exp $
 */
@Controller
@RequestMapping("/view")
public class PomeController {

	@Autowired
	@Qualifier("PomeService")
	private IPomeService service;

	/**
	 * 
	 * <p>功能描述：获得全部诗 TODO</p>
	 * <p>创建人：gao x</p>
	 * <p>创建日期：2014年2月15日</p>
	 *
	 * @return
	 */
	@RequestMapping(value = "query_all", method = RequestMethod.GET)
	public @ResponseBody
	Object queryAll() {
		return service.queryALL();
	}

	@RequestMapping(value = "query_services_max_poem", method = RequestMethod.POST)
	public @ResponseBody
	Object queryMaxPome() {
		return service.queryMax(1);
	}

	@RequestMapping(value = "query_services_max_sssue", method = RequestMethod.POST)
	public @ResponseBody
	Object queryMaxSssue() {
		return service.queryMax(2);
	}

	@RequestMapping(value = "add", method = RequestMethod.POST)
	public @ResponseBody
	String updatePome(@ModelAttribute("commod") PomeModel model) {
		if (model != null) {
			model.setId(1);
		} else {
			return "false";
		}
		if (service.updateModel(model))
			return "true";
		return "false";
	}

	@RequestMapping(value = "add_sssue", method = RequestMethod.POST)
	public @ResponseBody
	String updatePome_sssue(@ModelAttribute("commod") PomeModel model) {
		if (model != null) {
			model.setId(2);
		} else {
			return "false";
		}
		if (service.updateModel(model))
			return "true";
		return "false";
	}
}
